package com.ibeetl.admin.core.gen;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.beetl.core.GroupTemplate;
import org.beetl.core.Template;

import com.ibeetl.admin.core.gen.model.Attribute;
import com.ibeetl.admin.core.gen.model.Entity;

public class MdGen  implements AutoGen{

    static String CR = System.getProperty("line.separator");
    Entity entity = null;
    
    private String basicFunctionCode;
    
    public MdGen(String basicFunctionCode) {
        this.basicFunctionCode = basicFunctionCode;
    }
    
    @Override
    public void make(Target target, Entity entity) {
        this.entity = entity;
        GroupTemplate gt = target.getGroupTemplate();
        Template template = gt.getTemplate("/md/entity.md");
        template.binding("entity", entity);
        template.binding("target", target);
        template.binding("basicfunctionCode",basicFunctionCode);
        String content = template.render();
        target.flush(this, content);
    
    }
    
    @Override
    public String getName() {
        return entity.getCode()+".md";
    }
    
}

